﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQLHelper;
using System.Data;
using Bill.BasDLL.dao;
using Bill.BasDLL.ety;

namespace Bill.BasDLL.biz
{
    public class bizCodeRef
    {
        SQLHelp _sqlOraHelp = new SQLHelp();
        daoOraCodeRef doOraCodeRef;

        public bizCodeRef(SQLHelp iSqlOraHelp)
        {
            _sqlOraHelp = iSqlOraHelp;
            doOraCodeRef = new daoOraCodeRef(_sqlOraHelp);
        }
        /// <summary>
        /// 查找出所有代码的组别  
        /// </summary>
        /// <returns></returns>
        public IDictionary<string, string> GetCodeRefGrp()
        {
            IDictionary<string,string> dicCodeRefGrp = new Dictionary<string,string>();
            DataTable dt = doOraCodeRef.GetCodeRefGrp();
            if(dt!=null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    dicCodeRefGrp.Add(dr["ITEM"].ToString(), dr["ITEM_DESC"].ToString());
                }
            }
            return dicCodeRefGrp;
        }
        /// <summary>
        /// 查找出所有代码  
        /// </summary>
        /// <returns></returns>
        public IDictionary<string, string> GetCodeRefCode()
        {
            IDictionary<string, string> dicCodeRefCode = new Dictionary<string, string>();
            DataTable dt = doOraCodeRef.GetCodeRefCode();
            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    dicCodeRefCode.Add(dr["CODE"].ToString(), dr["CODE_DESC"].ToString());
                }
            }
            return dicCodeRefCode;
        }
        public IList<etyCodeRef> GetCodeRef(string item)
        {
            DataTable dt = doOraCodeRef.GetCodeRef(item);
            IList<etyCodeRef> ilCodeRef = TT.Common.Converts.ConvertToIList<etyCodeRef>(dt);
            return ilCodeRef;
        }
        public bool CheckExistCodeRef(etyCodeRef ieyCodeRef)
        {
            return doOraCodeRef.CheckExistCodeRef(ieyCodeRef);
        }
        public bool SaveCodeRef(etyCodeRef ieyCodeRef)
        {
            return doOraCodeRef.SaveCodeRef(ieyCodeRef);
        }
        public bool UpdateCodeRef(etyCodeRef newCodeRef,etyCodeRef oldCodeRef)
        {
            return doOraCodeRef.UpdateCodeRef(newCodeRef, oldCodeRef);
        }
        public bool DeleteCodeRef(etyCodeRef delCodeRef)
        {
            return doOraCodeRef.DeleteCodeRef(delCodeRef);
        }
    }
}
